package com.ymatou.iapi.exp.testcase;

import java.util.ArrayList;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.ymatou.iapi.exp.parameter.GetUserExpBean;
import com.ymatou.iapi.exp.parameter.GetUserExpDetailBean;
import com.ymatou.iapi.exp.service.GetUserExpCall;
import com.ymatou.iapi.exp.service.GetUserExpDetailCall;
import com.ymatou.iapi.userregister.parameter.UserRegisterInfoRequestDtoBean;
import com.ymatou.iapi.userregister.service.UserRegisterInfoRequestDtoCall;
import com.ymatou.iapi.userservice.parameter.LevelBean;
import com.ymatou.iapi.userservice.service.LevelCall;
import com.ymt.base.YmatouEasyCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.ExpCallService;
import com.ymttest.business.service.JUserCallService;
import com.ymttest.database.sqlwapper.ExpWapper;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;

/**
 * 获取用户经验值明细 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_GetUserExpDetail {
	private static GetUserExpDetailBean getuserexpdetailBean;
	private static GetUserExpDetailCall getuserexpdetailCall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取用户经验值明细");
	}

	@Before
	public void caseUp() {
		getuserexpdetailBean = new GetUserExpDetailBean();
		getuserexpdetailCall = new GetUserExpDetailCall();
		ExpCallService.resetFestivalRateConfig(1.0, false);
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getuserexpdetailCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category({ P1.class })
	@TestCase
	@Ignore
	// 签到不走经验值 走金币
	public void Tc_GetUserExpDetail_001() {
		Logger.start(true, "打开APP获得经验值,获取用户经验值明细成功");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			int uid = urrc.getUserid();
			ExpCallService.resetExp(uid, 100);
			ExpCallService.addExp(uid, 10, 100101);
			Thread.sleep(5000);
			// 这里可能存在查不出要等很久才出来的情况
			getuserexpdetailBean.setUserId(uid);
			getuserexpdetailCall.setData(getuserexpdetailBean);
			getuserexpdetailCall.callService();
			Logger.verifyEquals("success", getuserexpdetailCall.getErrorMessage(), "验证errormessage");
			Logger.verifyEquals("true", getuserexpdetailCall.getSuccess(), "验证success");
			Logger.verifyEquals("0", getuserexpdetailCall.getErrorCode(), "验证ErrorCode");
			try {
				JsonObject firstjs = getuserexpdetailCall.getJsonObject().getAsJsonArray("result").get(0).getAsJsonObject();
				Logger.verifyNotNull(firstjs.get("datetime").getAsString(), "验证datetime");
				Logger.verifyEquals(10, firstjs.get("exp").getAsInt(), "验证exp");
				Logger.verifyEquals("登录", firstjs.get("description").getAsString(), "验证description");
			} catch (Exception e) {
				Logger.fail(new Exception("没有查询到数据,这个场景可能需要等待一段时间才能查到"));
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P3.class })
	@TestCase
	public void Tc_GetUserExpDetail_002() {
		Logger.start(true, "不输入uid，失败");
		try {
			getuserexpdetailCall.setData(getuserexpdetailBean);
			getuserexpdetailCall.callService();
			Logger.verifyEquals("success", getuserexpdetailCall.getErrorMessage(), "验证errormessage");
			Logger.verifyEquals("true", getuserexpdetailCall.getSuccess(), "验证success");
			Logger.verifyEquals("0", getuserexpdetailCall.getErrorCode(), "验证ErrorCode");
			int size = getuserexpdetailCall.getJsonObject().getAsJsonArray("result").size();
			Logger.verifyEquals(0, size, "验证size");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	@Ignore
	// 缺少数据
	public void Tc_GetUserExpDetail_003() {
		Logger.start(true, "初始值导入,获取用户经验值明细成功");
		try {
			// TODO 补全case代码
			org.junit.Assert.fail();
			getuserexpdetailCall.setData(getuserexpdetailBean);
			getuserexpdetailCall.callService();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetUserExpDetail_004() {
		Logger.start(true, "购买商品获得经验值,获取用户经验值明细成功");
		try {
			int uid = 4;
			ExpCallService.resetExp(uid, 0);
			ExpCallService.addExp(uid, 20, 100102);
			getuserexpdetailBean.setUserId(uid);
			getuserexpdetailCall.setData(getuserexpdetailBean);
			getuserexpdetailCall.callService();
			Logger.verifyEquals("success", getuserexpdetailCall.getErrorMessage(), "验证errormessage");
			Logger.verifyEquals("true", getuserexpdetailCall.getSuccess(), "验证success");
			Logger.verifyEquals("0", getuserexpdetailCall.getErrorCode(), "验证ErrorCode");
			JsonObject firstjs = getuserexpdetailCall.getJsonObject().getAsJsonArray("result").get(0).getAsJsonObject();
			Logger.verifyNotNull(firstjs.get("datetime").getAsString(), "验证datetime");
			Logger.verifyEquals(20, firstjs.get("exp").getAsInt(), "验证exp");
			Logger.verifyEquals("购物-确认收货", firstjs.get("description").getAsString(), "验证description");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetUserExpDetail_005() {
		Logger.start(true, "job进行购买频率统计获得经验值,获取用户经验值明细成功");
		// delete from user_exp where userid > 5000 job会计算全部用户 测试时需要干掉用户否则会不执行
		try {
			int uid = 5;
			ExpCallService.resetExp(uid, 100);
			for (int i = 0; i < 4; i++) {
				ExpCallService.addExp(uid, 20, 100102);
			}
			Thread.sleep(1000);
			String starttime = YMTDateUtil.getBeforeOrNextDay(-1, "yyyy-MM-dd");
			String endtime = YMTDateUtil.getBeforeOrNextDay(1, "yyyy-MM-dd");
			String url = "http://exp.iapi.ymatou.com/api/job?name=userPurchaseFrequencyTask&startTime=" + starttime + "&endTime=" + endtime;
			// /api/job?name=userPurchaseFrequencyTask (用户购买频率统计获得经验值)
			// 这里需要批量计算 可能会有很长时间的延迟
			YmatouEasyCall ec = new YmatouEasyCall(url, "GET", "PARAM");
			ec.callService();
			Thread.sleep(5000);
			getuserexpdetailBean.setUserId(uid);
			getuserexpdetailCall.setData(getuserexpdetailBean);
			getuserexpdetailCall.callService();
			Logger.verifyEquals("success", getuserexpdetailCall.getErrorMessage(), "验证errormessage");
			Logger.verifyEquals("true", getuserexpdetailCall.getSuccess(), "验证success");
			Logger.verifyEquals("0", getuserexpdetailCall.getErrorCode(), "验证ErrorCode");
			JsonObject firstjs = getuserexpdetailCall.getJsonObject().getAsJsonArray("result").get(0).getAsJsonObject();
			Logger.verifyNotNull(firstjs.get("datetime").getAsString(), "验证datetime");
			if( firstjs.get("description").getAsString().contains("购物")){
				Thread.sleep(10000);
				getuserexpdetailCall.callService();
				firstjs = getuserexpdetailCall.getJsonObject().getAsJsonArray("result").get(0).getAsJsonObject();
			}
			Logger.verifyEquals(100, firstjs.get("exp").getAsInt(), "验证exp");
			Logger.verifyEquals("每月3次购物额外奖励", firstjs.get("description").getAsString(), "验证description");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetUserExpDetail_006() {
		Logger.start(true, "主动评价订单获得经验值,获取用户经验值明细成功");
		try {
			int uid = 6;
			ExpCallService.resetExp(uid, 0);
			ExpCallService.addExp(uid, 30, 100104);
			getuserexpdetailBean.setUserId(uid);
			getuserexpdetailCall.setData(getuserexpdetailBean);
			getuserexpdetailCall.callService();
			Logger.verifyEquals("success", getuserexpdetailCall.getErrorMessage(), "验证errormessage");
			Logger.verifyEquals("true", getuserexpdetailCall.getSuccess(), "验证success");
			Logger.verifyEquals("0", getuserexpdetailCall.getErrorCode(), "验证ErrorCode");
			JsonObject firstjs = getuserexpdetailCall.getJsonObject().getAsJsonArray("result").get(0).getAsJsonObject();
			Logger.verifyNotNull(firstjs.get("datetime").getAsString(), "验证datetime");
			Logger.verifyEquals(30, firstjs.get("exp").getAsInt(), "验证exp");
			Logger.verifyEquals("评价订单", firstjs.get("description").getAsString(), "验证description");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	@Ignore
	// 新上线不调用 程序控制2017.7.1 之后才开始进行扣分操作
	public void Tc_GetUserExpDetail_007() {
		Logger.start(true, "job进行统计持续无经验值新增记录者扣除经验值,获取用户经验值明细成功");
		try {
			// delete from user_exp where userid > 5000 job会计算全部用户
			// 测试时需要干掉用户否则会不执行
			// /api/job?name=inactivityUserTask (统计持续无经验值新增记录者扣除经验值)
			int uid = 7;
			ExpCallService.resetExp(uid, 50);
			new ExpWapper().deleteuserexpdetail(uid, null, null, null);
			Thread.sleep(1000);
			String starttime = YMTDateUtil.getBeforeOrNextDay(-1, "yyyy-MM-dd");
			String endtime = YMTDateUtil.getBeforeOrNextDay(1, "yyyy-MM-dd");
			String url = "http://exp.iapi.ymatou.com/api/job?name=inactivityUserTask&startTime=" + starttime + "&endTime=" + endtime;
			YmatouEasyCall ec = new YmatouEasyCall(url, "GET", "PARAM");
			ec.callService();
			Thread.sleep(5000);
			getuserexpdetailBean.setUserId(uid);
			getuserexpdetailCall.setData(getuserexpdetailBean);
			getuserexpdetailCall.callService();
			Logger.verifyEquals("success", getuserexpdetailCall.getErrorMessage(), "验证errormessage");
			Logger.verifyEquals("true", getuserexpdetailCall.getSuccess(), "验证success");
			Logger.verifyEquals("0", getuserexpdetailCall.getErrorCode(), "验证ErrorCode");
			JsonObject firstjs = getuserexpdetailCall.getJsonObject().getAsJsonArray("result").get(0).getAsJsonObject();
			Logger.verifyNotNull(firstjs.get("datetime").getAsString(), "验证datetime");
			Logger.verifyEquals(-30, firstjs.get("exp").getAsInt(), "验证exp");
			Logger.verifyEquals("3个月未使用", firstjs.get("description").getAsString(), "验证description");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetUserExpDetail_008() {
		Logger.start(true, "订单取消扣除经验值,获取用户经验值明细成功");
		try {
			int uid = 8;
			ExpCallService.resetExp(uid, 0);
			ExpCallService.addExp(uid, 30, 1002021);
			getuserexpdetailBean.setUserId(uid);
			getuserexpdetailCall.setData(getuserexpdetailBean);
			getuserexpdetailCall.callService();
			Logger.verifyEquals("success", getuserexpdetailCall.getErrorMessage(), "验证errormessage");
			Logger.verifyEquals("true", getuserexpdetailCall.getSuccess(), "验证success");
			Logger.verifyEquals("0", getuserexpdetailCall.getErrorCode(), "验证ErrorCode");
			JsonObject firstjs = getuserexpdetailCall.getJsonObject().getAsJsonArray("result").get(0).getAsJsonObject();
			Logger.verifyNotNull(firstjs.get("datetime").getAsString(), "验证datetime");
			Logger.verifyEquals(-30, firstjs.get("exp").getAsInt(), "验证exp");
			Logger.verifyEquals("订单退款", firstjs.get("description").getAsString(), "验证description");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetUserExpDetail_009() {
		Logger.start(true, "订单部分取消扣除经验值,获取用户经验值明细成功");
		try {
			int uid = 9;
			ExpCallService.resetExp(uid, 0);
			ExpCallService.addExp(uid, 30, 1002022);
			getuserexpdetailBean.setUserId(uid);
			getuserexpdetailCall.setData(getuserexpdetailBean);
			getuserexpdetailCall.callService();
			Logger.verifyEquals("success", getuserexpdetailCall.getErrorMessage(), "验证errormessage");
			Logger.verifyEquals("true", getuserexpdetailCall.getSuccess(), "验证success");
			Logger.verifyEquals("0", getuserexpdetailCall.getErrorCode(), "验证ErrorCode");
			JsonObject firstjs = getuserexpdetailCall.getJsonObject().getAsJsonArray("result").get(0).getAsJsonObject();
			Logger.verifyNotNull(firstjs.get("datetime").getAsString(), "验证datetime");
			Logger.verifyEquals(-30, firstjs.get("exp").getAsInt(), "验证exp");
			Logger.verifyEquals("订单退款", firstjs.get("description").getAsString(), "验证description");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	@Ignore
	// 20170502 产线bug 对经验值数据 每月交易次数不到3次依然增加了每月3次购物额外奖励
	public void Tc_GetUserExpDetail_010() {
		Logger.start(true, "查询明细");
		try {
			int uid = 0;
			ArrayList<String> lines = TestDataManager.getLines("0502.txt");
			for (String s : lines) {
				String[] ss = s.split(" ");
				uid = Integer.valueOf(ss[0]);
				int init = Integer.valueOf(ss[1]);
				getuserexpdetailBean.setUserId(uid);
				getuserexpdetailCall.setData(getuserexpdetailBean);
				getuserexpdetailCall.callService();
				JsonArray list = getuserexpdetailCall.getJsonObject().getAsJsonArray("result");
				Integer exps = 0;
				for (JsonElement jsonElement : list) {
					String s1 = jsonElement.getAsJsonObject().get("description").getAsString();
					exps = exps + jsonElement.getAsJsonObject().get("exp").getAsInt();
					Logger.debug(s1);
					if (s1.equals("每月3次购物额外奖励")) {
						Logger.debug(uid + "============" + jsonElement.toString());
						TestDataManager.appendFileToLine("0502temp.txt", uid + ":" + jsonElement.toString());
					}
				}
				// 验证经验总和
				GetUserExpBean getuserexpBean = new GetUserExpBean();
				GetUserExpCall getuserexpCall = new GetUserExpCall();
				getuserexpBean.setUserId(uid);
				getuserexpCall.setData(getuserexpBean);
				getuserexpCall.callService();
				int rexp = getuserexpCall.getJsonObject().getAsJsonObject("result").get("exp").getAsInt();
				int level = getuserexpCall.getJsonObject().getAsJsonObject("result").get("level").getAsInt();
				// 验证等级是否正确
				LevelBean LevelBean = new LevelBean();
				LevelCall LevelCall = new LevelCall();
				LevelBean.setUserId(uid);
				LevelCall.setData(LevelBean);
				LevelCall.callService();
				JsonObject js = LevelCall.getJsonObject().getAsJsonObject("Result");
				int ulv = js.get("Level").getAsInt();
				exps += init;
				if (exps != rexp) {
					Logger.debug(uid + "============experror");
					TestDataManager.appendFileToLine("0502temp.txt", uid + ":" + exps + ":" + rexp);
				}
				if (ulv != level) {
					Logger.debug(uid + "============levelerror");
					TestDataManager.appendFileToLine("0502temp.txt", uid + ":" + ulv + ":" + level);
				}
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetUserExpDetail_011() {
		Logger.start(true, "job进行购买频率统计获得经验值,次数不足时不增加情况1购买2次签到1次JIRACONN-10501");
		try {
			// 场景为经验值增加条数超过3条但是购买记录不足3条,之前会把签到也算在3次内
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			int uid = urrc.getUserid();
			ExpCallService.resetExp(uid, 0);
			for (int i = 0; i < 2; i++) {
				ExpCallService.addExp(uid, 20, 100102);
			}
			ExpCallService.addExp(uid, 20, 100104);
			Thread.sleep(1000);
			String starttime = YMTDateUtil.getBeforeOrNextDay(-1, "yyyy-MM-dd");
			String endtime = YMTDateUtil.getBeforeOrNextDay(1, "yyyy-MM-dd");
			String url = "http://exp.iapi.ymatou.com/api/job?name=userPurchaseFrequencyTask&startTime=" + starttime + "&endTime=" + endtime;
			// /api/job?name=userPurchaseFrequencyTask (用户购买频率统计获得经验值)

			YmatouEasyCall ec = new YmatouEasyCall(url, "GET", "PARAM");
			ec.callService();
			Thread.sleep(5000);
			getuserexpdetailBean.setUserId(uid);
			getuserexpdetailCall.setData(getuserexpdetailBean);
			getuserexpdetailCall.callService();
			Logger.verifyEquals("success", getuserexpdetailCall.getErrorMessage(), "验证errormessage");
			Logger.verifyEquals("true", getuserexpdetailCall.getSuccess(), "验证success");
			Logger.verifyEquals("0", getuserexpdetailCall.getErrorCode(), "验证ErrorCode");
			JsonArray firstjs = getuserexpdetailCall.getJsonObject().getAsJsonArray("result");
			Logger.verifyEquals(3, firstjs.size(), "验证明细条数");
			for (JsonElement jsonElement : firstjs) {
				Logger.verifyNotEquals("每月3次购物额外奖励", jsonElement.getAsJsonObject().get("description").getAsString(), "验证description");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetUserExpDetail_012() {
		Logger.start(true, "job进行购买频率统计获得经验值,购买后取消不算次数");
		try {
			int uid = 12;
			ExpCallService.resetExp(uid, 0);
			for (int i = 0; i < 4; i++) {
				ExpCallService.addExp(uid, 20, 1002021);
			}
			Thread.sleep(1000);
			String starttime = YMTDateUtil.getBeforeOrNextDay(-1, "yyyy-MM-dd");
			String endtime = YMTDateUtil.getBeforeOrNextDay(1, "yyyy-MM-dd");
			String url = "http://exp.iapi.ymatou.com/api/job?name=userPurchaseFrequencyTask&startTime=" + starttime + "&endTime=" + endtime;
			// /api/job?name=userPurchaseFrequencyTask (用户购买频率统计获得经验值)

			YmatouEasyCall ec = new YmatouEasyCall(url, "GET", "PARAM");
			ec.callService();
			Thread.sleep(5000);
			getuserexpdetailBean.setUserId(uid);
			getuserexpdetailCall.setData(getuserexpdetailBean);
			getuserexpdetailCall.callService();
			Logger.verifyEquals("success", getuserexpdetailCall.getErrorMessage(), "验证errormessage");
			Logger.verifyEquals("true", getuserexpdetailCall.getSuccess(), "验证success");
			Logger.verifyEquals("0", getuserexpdetailCall.getErrorCode(), "验证ErrorCode");
			JsonArray firstjs = getuserexpdetailCall.getJsonObject().getAsJsonArray("result");
			Logger.verifyEquals(8, firstjs.size(), "验证明细条数");
			for (JsonElement jsonElement : firstjs) {
				Logger.verifyNotEquals("每月3次购物额外奖励", jsonElement.getAsJsonObject().get("description").getAsString(), "验证description");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	// @Ignore
	// 新上线不调用 程序控制2017.7.1 之后才开始进行扣分操作
	public void Tc_GetUserExpDetail_013() {
		Logger.start(false, "job进行统计持续无经验值新增记录者扣除经验值,取消订单不扣除");
		try {
			// /api/job?name=inactivityUserTask (统计持续无经验值新增记录者扣除经验值)
			int uid = 13;
			ExpCallService.resetExp(uid, 0);
			new ExpWapper().deleteuserexpdetail(uid, null, null, null);
			ExpCallService.addExp(uid, 30, 1002021);
			Thread.sleep(1000);
			String starttime = YMTDateUtil.getBeforeOrNextDay(-1, "yyyy-MM-dd");
			String endtime = YMTDateUtil.getBeforeOrNextDay(1, "yyyy-MM-dd");
			String url = "http://exp.iapi.ymatou.com/api/job?name=inactivityUserTask&startTime=" + starttime + "&endTime=" + endtime;
			YmatouEasyCall ec = new YmatouEasyCall(url, "GET", "PARAM");
			ec.callService();
			Thread.sleep(5000);
			getuserexpdetailBean.setUserId(uid);
			getuserexpdetailCall.setData(getuserexpdetailBean);
			getuserexpdetailCall.callService();
			Logger.verifyEquals("success", getuserexpdetailCall.getErrorMessage(), "验证errormessage");
			Logger.verifyEquals("true", getuserexpdetailCall.getSuccess(), "验证success");
			Logger.verifyEquals("0", getuserexpdetailCall.getErrorCode(), "验证ErrorCode");
			JsonArray firstjs = getuserexpdetailCall.getJsonObject().getAsJsonArray("result");
			Logger.verifyEquals(2, firstjs.size(), "验证明细条数");
			for (JsonElement jsonElement : firstjs) {
				Logger.verifyNotEquals("3个月未使用", jsonElement.getAsJsonObject().get("description").getAsString(), "验证description");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetUserExpDetail_014() {
		Logger.start(true, "job进行购买频率统计获得经验值,次数不足时不增加情况2购买评价2次JIRACONN-10501");
		try {
			// 场景为经验值增加条数超过3条但是购买记录不足3条,之前会把签到也算在3次内
			int uid = 11;
			ExpCallService.resetExp(uid, 0);
			for (int i = 0; i < 2; i++) {
				ExpCallService.addExp(uid, 20, 100102);
				ExpCallService.addExp(uid, 20, 100104);
			}
			Thread.sleep(1000);
			String starttime = YMTDateUtil.getBeforeOrNextDay(-1, "yyyy-MM-dd");
			String endtime = YMTDateUtil.getBeforeOrNextDay(1, "yyyy-MM-dd");
			String url = "http://exp.iapi.ymatou.com/api/job?name=userPurchaseFrequencyTask&startTime=" + starttime + "&endTime=" + endtime;
			// /api/job?name=userPurchaseFrequencyTask (用户购买频率统计获得经验值)

			YmatouEasyCall ec = new YmatouEasyCall(url, "GET", "PARAM");
			ec.callService();
			Thread.sleep(5000);
			getuserexpdetailBean.setUserId(uid);
			getuserexpdetailCall.setData(getuserexpdetailBean);
			getuserexpdetailCall.callService();
			Logger.verifyEquals("success", getuserexpdetailCall.getErrorMessage(), "验证errormessage");
			Logger.verifyEquals("true", getuserexpdetailCall.getSuccess(), "验证success");
			Logger.verifyEquals("0", getuserexpdetailCall.getErrorCode(), "验证ErrorCode");
			JsonArray firstjs = getuserexpdetailCall.getJsonObject().getAsJsonArray("result");
			Logger.verifyEquals(4, firstjs.size(), "验证明细条数");
			for (JsonElement jsonElement : firstjs) {
				Logger.verifyNotEquals("每月3次购物额外奖励", jsonElement.getAsJsonObject().get("description").getAsString(), "验证description");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_GetUserExpDetail_015() {
		Logger.start(true, "job进行购买频率统计获得经验值,部分购买后取消不算次数");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			int uid = urrc.getUserid();
			ExpCallService.resetExp(uid, 0);
			for (int i = 0; i < 4; i++) {
				ExpCallService.addExp(uid, 20, 1002022);
			}
			Thread.sleep(1000);
			String starttime = YMTDateUtil.getBeforeOrNextDay(-1, "yyyy-MM-dd");
			String endtime = YMTDateUtil.getBeforeOrNextDay(1, "yyyy-MM-dd");
			String url = "http://exp.iapi.ymatou.com/api/job?name=userPurchaseFrequencyTask&startTime=" + starttime + "&endTime=" + endtime;
			// /api/job?name=userPurchaseFrequencyTask (用户购买频率统计获得经验值)

			YmatouEasyCall ec = new YmatouEasyCall(url, "GET", "PARAM");
			ec.callService();
			Thread.sleep(5000);
			getuserexpdetailBean.setUserId(uid);
			getuserexpdetailCall.setData(getuserexpdetailBean);
			getuserexpdetailCall.callService();
			Logger.verifyEquals("success", getuserexpdetailCall.getErrorMessage(), "验证errormessage");
			Logger.verifyEquals("true", getuserexpdetailCall.getSuccess(), "验证success");
			Logger.verifyEquals("0", getuserexpdetailCall.getErrorCode(), "验证ErrorCode");
			JsonArray firstjs = getuserexpdetailCall.getJsonObject().getAsJsonArray("result");
			Logger.verifyEquals(12, firstjs.size(), "验证明细条数");
			Logger.verifyIsContains(false, getuserexpdetailCall.getReturnData().contains("每月3次购物额外奖励"), "验证部分退款无奖励");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	@Ignore
	//签到不再进入经验,走金币
	public void Tc_GetUserExpDetail_016() {
		Logger.start(true, "节日打开APP获得经验值,获取用户经验值明细成功");
		try {
			ExpCallService.resetFestivalRateConfig(1.2, true);
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);

			JsonObject registerResult = urrc.getJsonObject().get("Result").getAsJsonObject();
			String token = registerResult.get("Token").getAsString();
			int uid = urrc.getUserid();
			ExpCallService.resetExp(uid, 100);
			ExpCallService.addExp(uid, 10, 100101);
			Thread.sleep(1000);
			getuserexpdetailBean.setUserId(uid);
			getuserexpdetailCall.setData(getuserexpdetailBean);
			getuserexpdetailCall.callService();	
			Logger.verifyEquals("success", getuserexpdetailCall.getErrorMessage(), "验证errormessage");
			Logger.verifyEquals("true", getuserexpdetailCall.getSuccess(), "验证success");
			Logger.verifyEquals("0", getuserexpdetailCall.getErrorCode(), "验证ErrorCode");
			JsonObject firstjs = getuserexpdetailCall.getJsonObject().getAsJsonArray("result").get(0).getAsJsonObject();
			Logger.verifyNotNull(firstjs.get("datetime").getAsString(), "验证datetime");
			Logger.verifyEquals(12, firstjs.get("exp").getAsInt(), "验证exp");
			Logger.verifyEquals("登录", firstjs.get("description").getAsString(), "验证description");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}